<?php

namespace Infrastructure;

class ViewBuilder {
            
    protected $_request;
    
    protected $_content;
    
    public function __construct($request) {
        $this->_request = $request;
    }
    
    public function build($params = []) {
        
        extract($params);
        
        ob_start();
        
        include APPLICATION_PATH . '/../Views/' 
                  . $this->_request['controller'] 
                  . '/' . $this->_request['action'] 
                  . '.php';
        
        $this->_content = ob_get_contents();
        
        ob_end_clean();
        
        include APPLICATION_PATH . '/../Views/layout.php';
    }    
    
    public function renderContent() {
        return $this->_content;
    }        
}

